<?php
/*
此控制器用于控制用户设置

itemnum    学生进行随机练习的答题量
itemid     题目编号
openid     微信用户标识
*/	

namespace Home\Controller;
use Common\Controller\MyInitController;
class SetupController extends MyInitController { 
	public function index(){
		
		$this->display();
		
	}
	public function changeTheme(){
		$data	=	I("post.");
		$Setup	=	D("setup");
		$isexitst	=	$Setup->where("openid	='{$data['id']}' AND isdelete = 0")->find();
		if(is_null($isexitst)){
			$result	=	$Setup->where("openid	='{$data['id']}' AND isdelete = 0")->add(array('value'=>$data['themes'],'item'=>'theme','openid'=>$data['id']));	
		}else
			$result	=	$Setup->where("openid	='{$data['id']}' AND isdelete = 0")->save(array('value'=>$data['themes'],'item'=>'theme'));
		
		if($result){
			$this->ajaxReturn('Done!');
		}else	{
			$this->ajaxReturn('there is some error...');
			//$this->ajaxReturn(array('value'=>$data['themes'],'item'=>'theme'));
		}
		
		
	}
	public function profile(){
		$this->openid = 'o_88Bj9DhZ2nylfNYAzf4G66wrMo';
		$openid	=	$this->openid;
		
		$Class	=	D('class');
		$class	=	$Class->find($openid);
		var_dump($class);
		$this->assign("inform",$inform);
		$this->display();
	}
	
}




?>